#include #include #include //structure record struct invent { int number, quantity; float price; }; //function prototype void create(); void display(); void main() { char choice; cout << " Menu Choice\n"; cout << "A. Create a file\n"; cout << "D. Display Data and Total Inventory\n\n"; cout << "Select either A or D "; cin >> choice; switch (toupper(choice)) { case 'A': create(); break; case 'D': display(); break; default: cout << "Error\n\n"; } }//end main void create() { ofstream outfile; invent inventory; outfile.open("data.dat"); cout << "Enter item number or -1 to quit "; cin >> inventory.number; while (inventory.number != -1) { cout << "Enter quantity and price separated with a space "; cin >> inventory.quantity >> inventory.price; outfile << inventory.number << " " << inventory.quantity << " " << inventory.price << endl; cout << "Enter item number or -1 to quit "; cin >> inventory.number; } outfile.close(); }//end create void display() { ifstream infile; invent inventory; float total=(float)0.0; infile.open("data.dat"); cout << "\nInv number Quantity Price\n\n"; infile >> inventory.number >> inventory.quantity >> inventory.price; while (!infile.eof()) { total += inventory.price * inventory.quantity; cout << " " << inventory.number << " " << inventory.quantity << " $" << inventory.price << endl; infile >> inventory.number >> inventory.quantity >> inventory.price; } infile.close(); cout << "\nTotal inventory $" << total << endl<